package com.yuchen.bearrecord.dto;

import com.yuchen.bearrecord.entity.Drug;
import lombok.Data;

import java.time.LocalDate;
import java.time.temporal.ChronoUnit;

@Data
public class ExpireDrugDto {
    private final Long id;
    private final String drugName;
    private final Integer remainDays;
    private final LocalDate expireDate;
    private final String surplus;
    private final String img;

    public ExpireDrugDto(Drug drug) {
        this.id = drug.getId();
        this.drugName = drug.getDrugName();
        this.expireDate = drug.getExpireDate();
        this.surplus = drug.getSurplus();
        this.img = drug.getImg();

        LocalDate today = LocalDate.now();
        this.remainDays = (int) ChronoUnit.DAYS.between(today, this.expireDate);
    }
}
